home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9027 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  10.0 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.ada,comp.lang.c
  4. Subject: Re: C/C++ knocks the crap out of Ada
  5. Date: 04 Mar 1996 22:53:15 GMT
  6. Organization: Los Alamos National Laboratory
  7. Distribution: world
  8. Message-ID: <TANMOY.96Mar4155315@qcd.lanl.gov>
  9. References: <JSA.96Feb16135027@organon.com> <4gaa6l$8mk@post.gsfc.nasa.gov>
  10.     <4gd94r$isu@mack.rt66.com> <1996Feb22.005518.13396@leeweyr.sccsi.com>
  11.     <4gvrffINNlqo@anvil.ugrad.cs.ubc.ca>
  12.     <4h4j31$1ga3@watnews1.watson.ibm.com>
  13.     <TANMOY.96Feb29144112@qcd.lanl.gov>
  14.     <4hf485$1mgv@watnews1.watson.ibm.com>
  15. NNTP-Posting-Host: qcd.lanl.gov
  16. Mime-Version: 1.0
  17. Content-Type: text
  18. In-reply-to: ncohen@watson.ibm.com's message of 4 Mar 1996 16:03:17 GMT
  19.  
  20. In article <4hf485$1mgv@watnews1.watson.ibm.com>
  21. ncohen@watson.ibm.com (Norman H. Cohen) writes:
  22.  
  23. NHC: Famous last words!  That's how we all started out! :-)
  24.  
  25. Yup. I am replying because there is precisely one mistake in your
  26. argument. (Most of it I actually agree with). But, as I am replying, I
  27. also put forth some arguments.
  28.  
  29. <snip>
  30. NHC: |> needed extensions. Things will change, and one should think of ANSI C
  31. NHC: |> as the only language that deserves to be called C anymore.
  32. NHC: 
  33. NHC: You'd better tell that to Bill Gates.
  34.  
  35. Most free software writers (including gnu) is shifting to my
  36. view :-) No argument, however: I predict that a few years from now
  37. nobody will bother about this particular issue.
  38.  
  39. <snip>
  40. NHC: The Ada language was originally designed in response to a set of
  41. NHC: requirements promulgated by its intended users.  The revision was driven
  42. NHC: by requirements that arose in the programming community, which provided
  43. NHC: plentiful input to a very open process.
  44.  
  45. I agree that the language design team got input from the target
  46. community: it however did not have the `field testing' that C got in
  47. its pre-standard phase. That is what I meant.
  48.  
  49. <snip>
  50. NHC: |> A minuscule community can have a well defined culture. A large and
  51. NHC: |> varied community cannot.
  52. NHC: 
  53. NHC: I don't think the difference is in the size of the communities, but in
  54. NHC: the nature of the languages.  Ada is designed specifically to facilitate
  55. NHC: disciplined software engineering.  One cannot understand the proper use
  56. NHC: of Ada features without understanding data abstraction, encapsulation,
  57. NHC: and narrow, precisely defined interfaces.  Therefore, these fundamental
  58. NHC: concepts are taught along with Ada.  C can also be used in a disciplined
  59. NHC: way, of course, but the language design does not focus on this; rather,
  60. NHC: it focuses on ensuring microefficiency, it invites programming by side
  61. NHC: effect, and it glorifies the use of obscure notation.
  62.  
  63. I agree that Ada probably does `encourage' safer practices, bu I do
  64. not think that is a major point: programming has only a little to do
  65. with the language. It is true that because many programmers from a
  66. generation of laxer software engineering practices still use C (and
  67. virtually none of them use Ada), as do a lot of people who both do not
  68. spend enough time in learning the language and cannot afford the
  69. runtime checks (a large fraction of the scientific community for
  70. example), many C programs are badly written. 
  71.  
  72. By the way, doesn't Ada require runtime checks? I thought it did, but
  73. I haven't looked at the language for a long time now: and have never
  74. programmed anything beyond `Hello world' in it. Most of the arguments
  75. in this post are incorrect if this assumption is false.
  76.  
  77. I do not think that C encourages either microefficiency, or
  78. programming by side effect or that it glorifies obscure notation
  79. except for very well established idioms which every language develops
  80. over time. I agree it does not do much to deter these bad practices
  81. (that is part of `the spirit of C': if a user is mad, let his/her
  82. programs display the same insanity), but saying it encourages such
  83. constructs is going too far.
  84.  
  85. NHC: |> NHC: rigorous validation suite to be approved for use on
  86. U.S. Department of 
  87. NHC: |> NHC: Defense projects, and the requirement in the standard
  88. itself to reject 
  89. NHC: |> NHC: certain forms of nonconformance at compile time, have led compiler
  90. NHC: |>
  91. NHC: |> So does the C standard.
  92. NHC: |>
  93. NHC: |> NHC: writers to implement the standard strictly and consistently.
  94. NHC: 
  95. NHC: Incorrect.  (And please stop cutting me off in mid-sentence! :-)) The C
  96. NHC: standard contains to requirement to detect any form of nonconformance at
  97. NHC: compile time.  Section 1.7 of the standard states, "A _conforming_hosted_
  98. NHC: _implementation_ shall accept any strictly conforming program.  A
  99. NHC: _conforming_freestanding_implementation_ shall accept any strictly
  100. NHC: conforming program in which the use of the features specified in the
  101. NHC: library section (Section 4) is confined to the contents of the standard
  102. NHC: <float.h>, <limits.h>, <stdarg.h>, and <stddef.h>." The converse ("A
  103. NHC: conforming implementation shall reject any program that is not strictly
  104. NHC: conforming.") is noticeably absent.  Indeed, the paragraph continues, "A
  105. NHC: conforming implementation may have extensions (including additional
  106. NHC: library functions), provided they do not alter the behavior of any
  107. NHC: strictly conforming program."
  108.  
  109. This is the only mistake in your post:
  110.  
  111. The standard requires a diagnostic whenever any constraint or syntax
  112. rule is violated. (5.1.1.3). After diagnosing the error, it can do
  113. whatsoever it pleases. 
  114.  
  115. In fact, sometimes vendors deliberately want something to invoke
  116. `undefined' behaviour instead of violating a constraint, so that they
  117. can provide an extension that does not need a diagnostic. Some of them
  118. (e.g. $ in a macro name) even get accepted. But, by and large, a
  119. compiler cannot silently compile these category of errors.
  120.  
  121. Errors which cannot be detected till run time in general (even if
  122. special cases can be) and a few occasional others lead to undefined
  123. behaviour. This is because the standard specifically did not think it
  124. necessary to put a run time penalty on any program: the implementation
  125. is allowed to put in checks, but is not required to.
  126.  
  127. The standard also does not say that incorrect programs `are to be
  128. rejected'. It simply says that a diagnostic is required.
  129.  
  130. Finally, some vendors get away thus: when you say `gcc' it
  131. compiles the GNU C language: which is distinct from C. Only when you
  132. say `gcc -pedantic' does it compile C code. As the standard cannot
  133. stop people from writing compilers for a language they do not even
  134. claim is the standard C, how can they stop this?
  135.  
  136. NHC: 
  137. NHC: |> No. What has lead to consistency is the small number of users with
  138. NHC: |> homogeneous needs.
  139. NHC: 
  140. NHC: The needs of the Ada community are hardly homogeneous.  Ada is
  141. NHC: implemented on a wide variety of processors, from supercomputers to
  142. NHC: embedded microprocessors and everything in between.  It is used for
  143.  
  144. But certainly not as wide as C? C is almost the first language to be
  145. implemented on every new chip that comes out: and I think that is
  146. because people `need' it. The Ada community is presumably a group of
  147. people who need to write code which will be reused for a long time,
  148. and probably on stable enough platforms that one does not have to work
  149. around machine/compiler deficiencies. It probably is also used by the
  150. community to whom safety is so important that it needs to be enforced
  151. by the language, instead of by programmer's habit and training; and by
  152. coding standards?
  153.  
  154. Am I wrong? If I am right, I have little to say about those needs. I
  155. am a scientist by profession: to me it is important to get my results
  156. with the current technology, and not have to wait for future
  157. advances. Heck, my theory is more likely to be wrong than my
  158. programming; and I would rather write my code in a `manifestly
  159. correct' way and thoroughly check my code (and cross check it); than
  160. write in a language that will check every operation that I do. I
  161. typically code for 3 months human time, and run for 1 year's cpu time:
  162. I do not really care if that 3 months become four, but I can't afford
  163. the 1 year becoming 13 months!
  164.  
  165. I have found that C can be used to write small understandable code
  166. with no overhead that I did not count on when I wrote my code. It is
  167. modular, portable and reusable. When even the small overhead is
  168. unacceptable (only in a tiny fraction of the code of course), I drop
  169. down to assembly, and thus give up on portability and
  170. reusability. That is one reason why I avoid C++ for example: the
  171. hidden costs are often unacceptable; forcing me into non-portable
  172. constructs more often. That is why I sometimes switch to Fortran:
  173. Fortran standard guarantees far less than the C standard, and hence
  174. the compilers can be much more aggressive without violating the
  175. standard.
  176.  
  177. All of this is a tradeoff between usability and efficiency. In the
  178. kind of job I do, C (or Fortran or C++ according to exactly who you
  179. talk to) is the compromise. I do not deny that depending on the
  180. relative importance of the various factors, the compromise could be
  181. different in other fields.
  182.  
  183. NHC: applications as varied as finance, command and control, systems
  184. NHC: programming, computer-aided design, VLSI design, medical instrumentation,
  185. NHC: and virtual reality, among others.
  186.  
  187. And do people use it for supercomputing? That is a non-rhetorical
  188. question: I really do not think that in most of the stuff I do I would
  189. like the run time checks (I do indeed code the really time intensive
  190. stuff in pseudo-assembly, the rest in statically tested C or
  191. Fortran. I run mainly on the CM5, and do not think that an Ada port
  192. exists for this machine). Or, can one switch off the checks in Ada?
  193.  
  194. If people do use this in real large scale computation, how much of the
  195. typical code is in `unsafe' modules? 
  196.  
  197. Cheers
  198. Tanmoy
  199. --
  200. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  201. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  202. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  203. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  204. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  205. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  206.